package yc.star.friend.controller;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import yc.star.common.controller.BaseController;
import yc.star.common.domain.AppResult;
import yc.star.common.domain.TableDataInfo;
import yc.star.friend.domain.exam.dto.ExamQueryDTO;
import yc.star.friend.domain.exam.dto.ExamRankDTO;
import yc.star.friend.domain.exam.vo.ExamVO;
import yc.star.friend.service.IExamService;

import java.util.List;

@RequestMapping("/exam")
@RestController
public class ExamController extends BaseController {

    @Autowired
    private IExamService examService;

    @GetMapping("/semiLogin/list")
    public TableDataInfo list (ExamQueryDTO examQueryDTO) {
        List<ExamVO> examVOList  = examService.list(examQueryDTO);
        return getTableDataInfo(examVOList);
    }

    @GetMapping("/semiLogin/redis/list")
    public TableDataInfo redisList (ExamQueryDTO examQueryDTO) {
        return examService.redisList(examQueryDTO);
    }

    @GetMapping("/rank/list")
    public TableDataInfo rankList (ExamRankDTO examRankDTO) {
        return examService.rankList(examRankDTO);
    }

    @GetMapping("/getFirstQuestion")
    public AppResult<String> getFirstQuestion (Long examId) {
        return AppResult.success(examService.getFirstQuestion(examId));
    }

    @GetMapping("/preQuestion")
    public AppResult<String> preQuestion(Long examId, Long questionId) {
        return AppResult.success(examService.preQuestion(examId, questionId));
    }

    @GetMapping("/nextQuestion")
    public AppResult<String> nextQuestion(Long examId, Long questionId) {
        return AppResult.success(examService.nextQuestion(examId, questionId));
    }



}